<?php

/**
 * Description of groupMenuEditDoAction
 *
 * @author francisc
 */

class groupMenuEditDoAction extends sfAction {

    public function execute($request) {
        $this->form = new GroupMenuForm();

        if ($this->processGroupMenu($request, $this->form)) {
            SqlEngineCore::get()->update(
                    array('table' => 'menu',
                          'columns' => array('restaurant_id' => $this->getUser()->getAttribute('current_restaurant_id'),
                                             'name' => $this->form->getValue('name'),
                                             'description' => $this->form->getValue('description')),
                          'where' => array('menu_id' => $request->getParameter('id'))));

            $this->error = 0;
        }
        else {
            $this->error = 1;
        }
    }

    protected function processGroupMenu(sfWebRequest $request, sfForm $form) {
        $form->bind($request->getParameter($form->getName()));

        return $form->isValid();
    }
}
